package com.javaee.experiment2;

import org.springframework.boot.CommandLineRunner;
import org.springframework.core.env.Environment;

import java.util.Objects;

/**
 * @author lzh
 */
public class CustomCommandLineRunner implements CommandLineRunner {

    private final Environment env;

    public CustomCommandLineRunner(Environment env) {
        this.env = env;
    }

    @Override
    public void run(String... args) throws Exception {
        System.out.println("利用springboot的自动装配CommandLineRunner");
        System.out.println("生成一个随机字符串".concat(Objects.requireNonNull(env.getProperty("random."))));
    }
}
